package com.gxs.tga.poc.domain.dto;

import java.io.Serializable;

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import com.gxs.tga.poc.domain.TgaWorksheet;

public class TgaWorksheetDto implements Serializable
{
	private static final long serialVersionUID = 1L;
	
	private String sheetInstanceId;
	private String parentWorksheetId;
	
	private String shellId;
	private String sheetId;
	private String sheetName;
	private String statusCollected = "PENDING";
	private String statusPreprod = "PENDING";
	private String statusProd = "PENDING";
	private String statusPsiqa = "PENDING";

	private String solutionId;
	private JSONObject sheetDataBlob;
	
	public TgaWorksheetDto(){}
	
	public TgaWorksheetDto(TgaWorksheet given,  boolean shouldInitializeData) throws ParseException
	{
		this.sheetInstanceId = given.getSheetInstanceId();
		this.parentWorksheetId = given.getParentWorksheetId();
		
		this.shellId = given.getShellId();
		this.sheetId = given.getSheetId();
		this.sheetName = given.getSheetName();
		this.statusCollected = given.getStatusCollected();
		this.statusPreprod = given.getStatusPreprod();
		this.statusProd = given.getStatusProd();
		this.statusPsiqa = given.getStatusPsiqa();
		
		this.solutionId = given.getTgaSolution().getSolutionId();
		
		if(shouldInitializeData || given.getSheetDataBlob() == null)
		{
			this.sheetDataBlob = null;
		}
		else
		{
			//
			// Add Data Card Information
			String jsonString = new String(given.getSheetDataBlob());
			JSONObject json = (JSONObject)new JSONParser().parse(jsonString);
			this.sheetDataBlob = json;
		}
	}

	public String getSheetInstanceId()
	{
		return sheetInstanceId;
	}

	public void setSheetInstanceId(String sheetInstanceId)
	{
		this.sheetInstanceId = sheetInstanceId;
	}

	public String getParentWorksheetId()
	{
		return parentWorksheetId;
	}

	public void setParentWorksheetId(String parentWorksheetId)
	{
		this.parentWorksheetId = parentWorksheetId;
	}

	public String getShellId()
	{
		return shellId;
	}

	public void setShellId(String shellId)
	{
		this.shellId = shellId;
	}

	public String getSheetId()
	{
		return sheetId;
	}

	public void setSheetId(String sheetId)
	{
		this.sheetId = sheetId;
	}

	public String getSheetName()
	{
		return sheetName;
	}

	public void setSheetName(String sheetName)
	{
		this.sheetName = sheetName;
	}

	public String getStatusCollected()
	{
		return statusCollected;
	}

	public void setStatusCollected(String statusCollected)
	{
		this.statusCollected = statusCollected;
	}

	public String getStatusPreprod()
	{
		return statusPreprod;
	}

	public void setStatusPreprod(String statusPreprod)
	{
		this.statusPreprod = statusPreprod;
	}

	public String getStatusProd()
	{
		return statusProd;
	}

	public void setStatusProd(String statusProd)
	{
		this.statusProd = statusProd;
	}

	public String getStatusPsiqa()
	{
		return statusPsiqa;
	}

	public void setStatusPsiqa(String statusPsiqa)
	{
		this.statusPsiqa = statusPsiqa;
	}

	public String getSolutionId()
	{
		return solutionId;
	}

	public void setSolutionId(String solutionId)
	{
		this.solutionId = solutionId;
	}

	public JSONObject getSheetDataBlob()
	{
		return sheetDataBlob;
	}

	public void setSheetDataBlob(JSONObject sheetDataBlob)
	{
		this.sheetDataBlob = sheetDataBlob;
	}
	
	

}
